#pragma GCC optimize(2, "Ofast", "inline")
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;

// 已知
int t;
int n, a, b;
// 未知

signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n;
        int mna = 1 << 30, mnb = 1 << 30;
        for (int i = 1; i <= n; i++)
        {
            cin >> a >> b;
            if (b < mnb) mna = a, mnb = b;
        }
        cout << mna + mnb << endl;
    }


    return 0;
}